package solitaire.deck;

import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.lang.Math;

public class Deck {
	
	private static int DECK_SIZE = 52;
	private static int SUIT_SIZE = 13;
	
	public Card[] deckCards;
	
	public Deck()
	{
		deckCards = new Card[DECK_SIZE];
		
		for (int i=0; i < SUIT_SIZE; i++)	{
			deckCards[i] = new Card(Suit.Hearts, Rank.getRankNumber(i));
    	}
    	for (int i=SUIT_SIZE; i < (SUIT_SIZE*2); i++)	{
    		deckCards[i] = new Card(Suit.Spades, Rank.getRankNumber(i-SUIT_SIZE));
    	}
    	for (int i=(SUIT_SIZE*2); i < (SUIT_SIZE*3); i++)	{
    		deckCards[i] = new Card(Suit.Diamonds, Rank.getRankNumber(i-(SUIT_SIZE*2)));
    	}
    	for (int i=(SUIT_SIZE*3); i < (SUIT_SIZE*4); i++)	{
    		deckCards[i] = new Card(Suit.Clubs, Rank.getRankNumber(i-(SUIT_SIZE*3)));
    	}
	}
	
	public Card[] Cards()
	{
		return deckCards;
	}
	
	public int size()
	{
		return DECK_SIZE;
	}
	
	public void shuffle()
	{
		for(int i = 0; i < DECK_SIZE; i++)
		{
			deckCards[i].turnCardDownSide();
		}
		
		for(int i = 0; i < DECK_SIZE; i++)
		{
			int random = (int)(Math.random()*51);
			Card temp = new Card(0);
			temp = deckCards[i];
			deckCards[i] = deckCards[random];
			deckCards[random] = temp;
		}
	}
}
